<?php
require_once VT_PLUGIN_DIR . "api/home.php";
require_once VT_PLUGIN_DIR . "api/wxapp.php";


add_action('rest_api_init', function (){
    /**
     * 小程序相关信息
     * 路径：/wp-json/lightv/v1/index
     */
    register_rest_route('lightv/v1', 'index', [
        'methods'  => 'GET',
        'callback' => function ($request) {
            $homeController = new \lightv\api\HomeController();
            return $homeController->index($request);
        }
    ]);

    /**
     * 微信小程序登录接口
     * 路径：/wp-json/vtheme/v1/wxapp-login
     */
    register_rest_route('lightv/v1', 'wxapp-login', [
        'methods'  => 'POST',
        'callback' => function ($request) {
            $wxapp = new \lightv\api\Wxapp();
            return $wxapp->login($request);
        }
    ]);
});
    




